package com.cqgc.dao;

import com.cqgc.domain.NewPassword;
import com.cqgc.domain.PageHelper;
import com.cqgc.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserDao {

    @Select("select * from user where account=#{account} and password = #{password} and state = 1")
    User Login(User user);

    @Update("update user set reg_time = #{regTime} where uid = #{uid}")
    int UpdateTime(User user);

    @Insert("insert into user values(null,#{account},#{name},#{role},#{lastLoginTime},#{regTime},#{password},1)")
    int addUser(User user);


    @Select("select * from user where state =1 limit #{currentPage},#{pageSize}")
    List<User> findAll(PageHelper pageHelper);

    @Select("select * from user where state = 1")
    List<User> findAllUser();

    @Update("update user set account=#{account},role=#{role} where uid=#{uid}")
    int editUser(User user);

    @Select("select * from user where uid = #{uid}")
    User findUserByUid(int uid);

    @Update("update user set password = #{newPassword} where uid = #{uid}")
    int editPassword(NewPassword newPassword);

    @Delete("delete from user where uid = #{uid}")
    int delUser(User user);

    @Update("update user set state = 0 where uid=#{uid}")
    int deleteUser(User user);
}
